package com.example.administrator.yuejian23.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.yuejian23.Activity.MySettingInfoActivity;
import com.example.administrator.yuejian23.Activity.MyShaiTuActivity;
import com.example.administrator.yuejian23.Activity.SettingActivity;
import com.example.administrator.yuejian23.Bean.Club;
import com.example.administrator.yuejian23.Bean.MyBean;
import com.example.administrator.yuejian23.Bean.MyCollect;
import com.example.administrator.yuejian23.Const;
import com.example.administrator.yuejian23.Fragment.MyFragment;
import com.example.administrator.yuejian23.Fragment.viewholder.MyViewHolder;
import com.example.administrator.yuejian23.R;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Administrator on 2017/10/31.
 */

public class SettingAdapter extends RecyclerView.Adapter {
    public TextView textview1;
    public TextView textview2;
    public TextView textview3;
    public TextView textview4;
    public TextView textview5;
    public Button edit_button;
    private View itemView;
    private List<MyBean> myBeanlist;
    private Context context;
    private LayoutInflater layoutInflater;
    public  TextView userid;
    public SettingAdapter(Context context,List<MyBean> myBeanlist){
        this.context=context;//保存上下文
        this.myBeanlist=myBeanlist;//显示内容
    }



    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
        View itemView=LayoutInflater.from(context).inflate(R.layout.item_user_setting,viewGroup,false);
        SettingViewHolder holder=new SettingViewHolder(itemView);
        return holder;

    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {

        SettingViewHolder settingViewHolder=(SettingViewHolder) viewHolder;
        MyBean myInfo=myBeanlist.get(position);
         final String address=Const.PIC_URL+myInfo.getPhoto();
        final String username=myInfo.getUser_name();
        final String password=myInfo.getPassword();
        Picasso.with(context).load(address).into(MyViewHolder.textView_Image);
     /*   UserGuanZhuViewHolder userGuanZhuViewHolder= (UserGuanZhuViewHolder) viewHolder;
        MyCollect guanzhu=myCollects.get(position);
        String guanzhu_name=guanzhu.getName();
        String guanzhu_pic= Const.PIC_URL+guanzhu.getThumb();
        userGuanZhuViewHolder.guanzhu_name.setText(guanzhu_name);
        Picasso.with(context).load(guanzhu_pic).into(userGuanZhuViewHolder.guanzhu_pic);*/
        settingViewHolder.textview1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //启动新的Activity-俱乐部详情
                Intent intent = new Intent(context, MySettingInfoActivity.class);
                intent.putExtra("UserName",username);
                intent.putExtra("mypic",address);
                intent.putExtra("Password",password);
                context.startActivity(intent);//启动Activity的时候要注意，加context
            }
        });

    }

    @Override
    public int getItemCount() {
        return 0;
    }
    public class SettingViewHolder extends RecyclerView.ViewHolder{


        public TextView textview1;
        public TextView textview2;
        public TextView textview3;
        public TextView textview4;
        public TextView textview5;
        public Button edit_button;
        public View itemView;

        public SettingViewHolder(View itemView) {
            super(itemView);
            this.itemView=itemView;
            textview1= (TextView) itemView.findViewById(R.id.contact_set);
            textview2= (TextView) itemView.findViewById(R.id.put_set);
            textview3= (TextView) itemView.findViewById(R.id.delete);
            textview4= (TextView) itemView.findViewById(R.id.yaoqing);
            textview5= (TextView) itemView.findViewById(R.id.help);
            edit_button= (Button) itemView.findViewById(R.id.exit_button);

        }
    }
}


